import axios from 'axios'
import {Message} from 'element-ui'
axios.defaults.timeout = 120000;

axios.interceptors.request.use(config =>{
  let token = localStorage.getItem('user')
//   console.log(token);
  if(token){
    config.headers.token = token
  }
  return config
})

axios.interceptors.response.use(function (response) {
    console.log(response);
    return response.data;
  }, function (error) {
    console.log(error);
    Message({
        message:('数据请求失败' + error),
        type:'warning'
    })
    return Promise.reject(error);
  });

export default axios